/*
 * Copyright (C) 2010 Seapeak.Xu
 *
 * fostmq may be copied only under the terms of the GNU General
 * Public License V3, which may be found in the fostmq source kit.
 *
 * Created on: 2010-9-19
 * Author: Seapeak.Xu
 */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#include "fost_typedef.h"
#include "fost_proc.h"

void daemon_init(bool isdaemon)
{
	if(isdaemon)
	{
		pid_t pid;

		if ((pid = fork()) != 0) {
			exit(0);
		}

		setsid();

		if ((pid = fork()) != 0) {
			exit(0);
		}

		chdir("/");
	}
	return;

}
